//
//  GMagazine.m
//  helpinrain
//
//  Created by Gang.Wang on 12-7-26.
//  Copyright (c) 2012年 Zhuhai Yuike Technology Co., Ltd. All rights reserved.
//

#import "GMagazine.h"
#import "GSection.h"

@implementation GMagazine

@synthesize sections = sections_;

- (void) dealloc
{
    YRelease(sections_)
    [super dealloc];
}

- (id) initWithXmlTree:(XMLParsedTree *)tree
{
    self = [super initWithXmlTree:tree];
    if (self) {
        self.name = [self.xmlTree attributeValueOfName:@"name" atPath:@"magazine"];
        self.description = [self.xmlTree attributeValueOfName:@"description" atPath:@"magazine"];
        
        NSMutableArray * temp_section = [[NSMutableArray alloc] initWithCapacity:3];
        for (XMLParsedTree * node in [self.xmlTree childrenTreeAtPath:@"magazine" nodeName:@"section"]) 
        {
            GSection * section= [[GSection alloc] initWithXmlTree:node];
            [temp_section addObject:section];
            YRelease(section)
        }
        
        self.sections = temp_section;
        YRelease(temp_section)        
    }
    return self;
}

@end
